<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>店面自营产品管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		fieldset{
			display:inline-block;width:100%;
		} 
		legend{
			font-family: "Microsoft YaHei" ! important;
		}
		#showPhoto{
			width:240px;height:300px;border-radius:5px;
		}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				rules:{
	                "retail_price": "ifMoney"
	            },
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			$("#photoFile").change(function() {
				global.displayAsImage(this, "showPhoto");
			});
		});
	</script>
</head>
<body>
	<form:form id="inputForm" class="form-input" modelAttribute="storeSelfProduct" action="${ctx}/base/storeSelfProduct/save" method="post" enctype="multipart/form-data">
		<form:hidden path="id"/>
		<form:hidden path="storeSelfProductCategory.id" value="${storeSelfProduct.storeSelfProductCategory.id}"/>
		<form:hidden path="image" value=""/>
		<div class="icon-buttons">
			<a href="${ctx}/base/storeSelfProduct/list?category_id=${storeSelfProduct.storeSelfProductCategory.id}" data-icon="back" data-iconpos="notext" data-role="button" data-inline="true">返回</a>
			<input type="submit" data-icon="check" data-iconpos="notext" value="保 存" data-inline="true"/>
		</div>
		<tags:message content="${message}"/>
		<div data-role="fieldcontain">
			<label for="storeSelfProductCategory.name">产品分类名称:</label>
			<form:input path="storeSelfProductCategory.name"  disabled="true" htmlEscape="false" readonly="readonly" maxlength="64" class="required"/>
		</div>
		<div data-role="fieldcontain">
			<label for="name">产品名称:</label>
			<form:input path="name" htmlEscape="false" maxlength="64" class="required"/>
		</div>
		<div data-role="fieldcontain">
			<label for="spec">产品规格:</label>
			<form:input path="spec" htmlEscape="false" maxlength="16" class="required"/>
		</div>
		<div data-role="fieldcontain">
			<label for="retail_price">零售价:</label>
			<form:input path="retail_price" htmlEscape="false" maxlength="50" class="required"/>
		</div>
		<div data-role="fieldcontain">
			<form:hidden path="image"/>
			<label for="photoFile">产品图片:</label>
			<input type="file" id="photoFile" name="photoFile" accept="image/*" capture="camera">
		</div>
		<div class="middleCls">
			<img id="showPhoto"  alt="产品预览" src="${ossPath}${storeSelfProduct.image}">
		</div>
	</form:form>
</body>
</html>
